﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using EduProject.Database;
using Bshop.BLL;
using System.Collections;

namespace EduProject.Areas.User.Controllers
{
    public class ProductDetailController : Controller
    {
        BShopEntities shopEntity = new BShopEntities();
        ProductInfo NewProduct = new ProductInfo();
    
        // GET: /User/ProductDetail/
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult XieZhuang(int typeId,string type,int PageIndex=1,int pageSize=9)
        {
            ViewBag.name = Session["userName"];
            //返回商品的功效信息
            //var  functionType=(from c in shopEntity.Type
            //                   where c.Id == typeId
            //                  select new {c.gongxiao}).FirstOrDefault();
            var functionType = (from c in shopEntity.Type
                                where c.Id == typeId
                                select new { c.gongxiao,c.Name}).FirstOrDefault();

            //ViewBag.arr = functionType.ToString().Replace("{ gongxiao =", "").Replace("\"", "").Replace("}","").Split(new char[] { '&' });
            ViewBag.arr = functionType.gongxiao.ToString().Split(new char[] { '&' });
            List<FunctionDetail> la = shopEntity.FunctionDetail.Where(c => c.TypeId == typeId).ToList();
            ViewBag.TypeArr = la;

            var product = NewProduct.GetTopSellingProduct(0,typeId);

            ViewBag.TypeName = functionType.Name.ToString();
            ViewBag.type = type;
            return View(product);
            
        }
      
	}
}